module PrismBreak {

    export class Region {
        private frameworkApp: PbApp;

        public Id: string;
        public Root: HTMLElement;
        public Type: RegionType;

        //ActiveView makes sense only if the region is of type 'OnlyOne'
        private ActiveView: View;


        constructor(frameworkApp: PbApp, id?: string, parent?: HTMLElement) {

            this.frameworkApp = frameworkApp
            this.Id = id;
            this.Root = parent;
            //this.Views = ];
            this.Type = PrismBreak.RegionType.OnlyOne;
        }

        public SetActiveView(view: View): void{
            if (this.Type === PrismBreak.RegionType.OnlyOne) {
                if (this.ActiveView) {
                    this.frameworkApp.ViewManager.DeactivateView(this.ActiveView);
                }

                this.ActiveView = view;
            }
        }

        //public AddView(view: View): void {


        //    if (this.Type === PrismBreak.RegionType.OnlyOne) {
        //        if (this.ActiveView) {
        //            this.RemoveView(this.ActiveView);
        //        }

        //        this.ActiveView = view;
        //    }

        //    view.Activate();

        //    var jnode = $(view.Node);

        //    jnode.removeClass(PrismBreak.ViewClass[PrismBreak.ViewClass.pb_invisible]);

        //    if (!jnode.hasClass(PrismBreak.ViewClass[PrismBreak.ViewClass.pb_visible])) {
        //        jnode.addClass(PrismBreak.ViewClass[PrismBreak.ViewClass.pb_visible]);
        //    }

        //}


        //public RemoveView(view: View): void {

        //    var jnode = $(view.Node);

        //    jnode.removeClass(PrismBreak.ViewClass[PrismBreak.ViewClass.pb_visible]);

        //    if (!jnode.hasClass(PrismBreak.ViewClass[PrismBreak.ViewClass.pb_invisible])) {
        //        jnode.addClass(PrismBreak.ViewClass[PrismBreak.ViewClass.pb_invisible]);
        //    }
        //    view.Deactivate();

        //    if (this.Type === PrismBreak.RegionType.OnlyOne) {
        //        this.ActiveView = null;

        //    }

        //}

    }
}